home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / cvs-1.8 / cvs-1 / cvs-1.8.1 / lib / valloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-06  |  434 b   |  26 lines

  1. /* valloc -- return memory aligned to the page size.  */
  2.  
  3. #ifdef HAVE_CONFIG_H
  4. #include "config.h"
  5. #endif
  6.  
  7. #include "system.h"
  8.  
  9. #ifndef HAVE_GETPAGESIZE
  10. #define getpagesize() 4096
  11. #endif
  12.  
  13. void *
  14. valloc (bytes)
  15.      size_t bytes;
  16. {
  17.   long pagesize;
  18.   char *ret;
  19.  
  20.   pagesize = getpagesize ();
  21.   ret = (char *) malloc (bytes + pagesize - 1);
  22.   if (ret)
  23.     ret = (char *) ((long) (ret + pagesize - 1) &~ (pagesize - 1));
  24.   return ret;
  25. }
  26.